#include "constants.h"

// init include client
if (X_Client) then {
	if (d_global_debug > 0) then { diag_log Format["(%1)[%2]: %3",diag_tickTime,"i_client.sqf","Starting Execution"]; };
	// marker type used for players
	d_p_marker = d_MarkerTypeL;
	if (! isNil("d_MarkerSizeL")) then {
		If (count d_MarkerSizeL > 1) then {	d_p_markerSize = d_MarkerSizeL; };
	};

	d_current_ai_num = 0;
	d_ai_punits = [];

	d_grasslayer_index = if (d_GrassAtStart) then {1} else {0};

	d_custom_layout = [];

	d_marker_vecs = [];
	
	X_MHQ_Respawn_Marker1 = [0,0,0];
	X_MHQ_Respawn_Marker2 = [0,0,0];

	// is engineer
	d_is_engineer = ["delta_1","delta_2","delta_3","delta_4","delta_5","delta_6","test_char"];

	// can build mash
	d_is_medic = ["alpha_6","bravo_3","bravo_6","charlie_6","echo_6","test_char"];

	// can build mg nest
	d_can_use_mgnests = ["alpha_3","alpha_7","charlie_3","charlie_7","bravo_4","echo_3","echo_7","test_char"];

	// can build mg nest
	d_can_use_aapods = ["alpha_4","alpha_8","charlie_4","charlie_8","echo_4","echo_8","test_char"];

	// can call in air drop
	d_can_call_drop = ["alpha_1","bravo_1","charlie_1","delta_1","echo_1","test_char"];

	// can use radio calls
	d_is_radiooperator = ["alpha_1","bravo_1","charlie_1","delta_1","echo_1","echo_5","charlie_5","alpha_5","bravo_7","test_char"];
	
	d_can_rescue = ["RESCUE","RESCUE2","test_char"];
	
	d_can_order_artillery = ["RESCUE","RESCUE2","test_char"];

	d_backpackclasses = [
		[ // US
			"US_Assault_Pack_EP1","US_Patrol_Pack_EP1","US_Backpack_EP1","DE_Backpack_Specops_EP1","CZ_Backpack_EP1","CZ_VestPouch_EP1",
			"BAF_AssaultPack_Special",
			"Tripod_Bag",
			"M252_US_Bag_EP1","M2HD_mini_TriPod_US_Bag_EP1","M2StaticMG_US_Bag_EP1","MK19_TriPod_US_Bag_EP1","TOW_TriPod_US_Bag_EP1",
			"BAF_GMG_ACOG_minitripod_bag","BAF_GPMG_Minitripod_D_bag","BAF_L2A1_ACOG_minitripod_bag","BAF_L2A1_ACOG_tripod_bag"
		],
		[ // East
			"TK_ALICE_Pack_EP1","TK_Assault_Pack_EP1",
			"Tripod_Bag",
			"2b14_82mm_TK_Bag_EP1","AGS_TK_Bag_EP1","KORD_TK_Bag_EP1","KORD_high_TK_Bag_EP1","TK_RPG_Backpack_EP1","Metis_TK_Bag_EP1",
			"2b14_82mm_TK_INS_Bag_EP1","AGS_TK_INS_Bag_EP1","DSHKM_TK_INS_Bag_EP1","DSHkM_Mini_TriPod_TK_INS_Bag_EP1","SPG9_TK_INS_Bag_EP1"
		]
	];
	
	if (isnil "d_helilift1_types") then { d_helilift1_types = []; };
	_lift_types = switch (d_own_side) do {
		case "WEST": {["LAV25","LAV25_HQ","HMMWV","HMMWV_Armored","MTVR","HMMWV_Avenger","HMMWV_M2","HMMWV_MK19","HMMWV_TOW","HMMWV_Ambulance","MtvrReammo","MtvrRefuel","MtvrRepair"]};
		case "EAST": {["BTR90","BTR90_HQ","GAZ_Vodnik_MedEvac","WarfareSalvageTruck_RU","KamazRepair","KamazRefuel","KamazReammo","Kamaz","KamazOpen","UAZ_RU"]};
		case "GUER": {[]};
	};

	if (count _lift_types > 0) then {d_helilift1_types = [d_helilift1_types, _lift_types] call XfarrayPushStack};
		
	// Here we set for each chopper which kind of vehicle it is able to lift, depending on the second value in the d_choppers array
	for "_i" from 0 to (count d_choppers - 1) do {
		_elem = d_choppers select _i;
		switch (_elem select 1) do {
			// Case 0, we can lift the defined types.
			case 0: {_elem set [count _elem, d_helilift1_types]};
			// Case 1, we cannot lift anything.
			case 1: {_elem set [count _elem, []]};
			// You can add special cases with choppers which can lift only certain types or new types.
		};
	};

	d_prim_weap_player = "";
	d_last_telepoint = 0;
	d_chophud_on = true;

	// show a welcome message in a chopper (mainly used to tell the player if it is a lift or wreck lift chopper).
	// false = disable it
	d_show_chopper_welcome = WithChopHud;

	if (d_global_debug > 5) then { 
		diag_log Format["d_create_bike : %1",d_create_bike];
		diag_log Format["d_check_ammo_load_vecs : %1",d_check_ammo_load_vecs];
		diag_log Format["d_choppers : %1",d_choppers];
		diag_log Format["d_p_vecs : %1",d_p_vecs];
		diag_log Format["d_is_engineer : %1",d_is_engineer];
		diag_log Format["d_is_medic : %1",d_is_medic];
		diag_log Format["d_can_use_mgnests : %1",d_can_use_mgnests];
		diag_log Format["d_can_call_drop : %1",d_can_call_drop];
		diag_log Format["d_helilift1_types : %1",d_helilift1_types];
	};

	// add action menu entries + scripts that will be executed to specific player types
	// if the first array is empty, then all players will get that action menu entry
	// default, nothing in it
	// you have to set fourth element allways to -1000
	// example:
	//	d_action_menus_type = [
	//		[[],"Whatever2", "whateverscript2.sqf", -1000], // ALL players will get the action menu entry "Whatever2"
	//		[["SoldierWMiner", "SoldierWAT","OfficerW"],"Whatever1", "whateverscript1.sqf", -1000] // only players of type SoldierWMiner, SoldierWAT and OfficerW will get the action menu entry "Whatever1"
	//	];
	// d_action_menus_type = [];

	// add action menu entries + scripts that will be executed to specific player units
	// if the first array is empty, then all players will get that action menu entry
	// default, nothing in it
	// you have to set fourth element allways to -1000
	// example:
	// 	d_action_menus_unit = [
	//		[[],"Whatever2", "whateverscript2.sqf", -1000], // ALL players will get the action menu entry "Whatever2"
	//		[["RESCUE", "delta_1","bravo_6"],"Whatever1", "whateverscript1.sqf", -1000] // only players who are RESCUE, delta_1 and bravo_6 will get the action menu entry "Whatever1"
	//	];
	// d_action_menus_unit = [];

	// add action menu entries to all or specific vehicles, default = none
	// example:
	// d_action_menus_vehicle = [
	// 		[[],"Whatever2", "whateverscript2.sqf", -1000], // will add action menu entry "Whatever2" to all vehicles
	// 		[["UH60MG", "M113_MHQ"],"Whatever1", "whateverscript1.sqf", -1000] // will add action menu entry "Whatever1" to chopper 1 and MHQ 1
	// 
	// ];
	// d_action_menus_vehicle = [];
		
	// We hide the "area_static_X" markers used by the mission maker
	_i = 1;
	_not_found = 0;
	While {_not_found < 5 } do {
		_marker_name = Format["area_static_%1",_i];
		if (d_global_debug > 5) then { diag_log Format["Hiding marker: %1",_marker_name]; };
		_marker_pos = getMarkerPos _marker_name;
		If ((_marker_pos select 0 == 0) And (_marker_pos select 1 == 0)) then {
			_not_found = _not_found + 1;
		} else {
			_marker_name setMarkerAlpha 0;
			if (d_global_debug > 5) then { diag_log Format["Hidden marker: %1",_marker_name]; };
		};
		_i = _i + 1;
	};
		
	// We hide the "markXX" markers used for debug
	_i = 1;
	_not_found = 0;
	While {_not_found < 5 } do {
		_marker_name = "mark00";
		if (_i < 10) then {
			_marker_name = Format["mark0%1",_i];
		} else {
			_marker_name = Format["mark%1",_i];
		};
		_marker_pos = getMarkerPos _marker_name;
		If ((_marker_pos select 0 == 0) And (_marker_pos select 1 == 0)) then {
			_not_found = _not_found + 1;
		} else {
			_marker_name setMarkerAlpha 0;
		};
		_i = _i + 1;
	};
	if (d_global_debug > 0) then { diag_log Format["(%1)[%2]: %3",diag_tickTime,"i_client.sqf","Ending Execution"]; };
};